<!--
  - Copyright (c) 2018.
  - 北京九思金信科技有限公司对该文件内容保留所有权利。
  - 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
  -->
  <template>
  <div class="infoSearch_box">
    <div class="infoSearch_title">
      <div class="search_box">
        <img src="@/assets/img/Back@3x.png" @click="returnHistory" alt>
        <!-- <input type="text" placeholder="搜索你感兴趣的应用" maxlength="20" v-model="aaaa"> -->
        <input type="text" placeholder="搜索" maxlength="20" v-model="searchInfoItem">
      </div>
      <i @click="returnHistory">取消</i>
    </div>
    <scroll class="infoSearch_list_box">
      <div class="infoSearch_list">
        <div class="infoSearch_list_item" v-for="item in searchlist" :key="item.id">
          <div class="infoSearch_list_item_img">
            <img v-lazy="queryImg(item.appImgId)" alt>
          </div>
          <div class="infoSearch_list_item_info">
            <!-- <span>{{item.messageTitle}}</span> -->
            <p>{{item.messageTitle}}</p>
            <div class="stylefont">{{item.messageContent}}</div>
          </div>
        </div>
        <div
          v-if="!searchlist.length && searchInfoItem "
          class="infoSearch_none_list"
        >没有搜索到任何关于“{{searchInfoItem}}”的消息</div>
        <div v-show="!searchlist.length && !searchInfoItem" class="infoSearch_none_list">搜索信息</div>
      </div>
    </scroll>
  </div>
</template>
  
  <script>
import Scroll from "@/components/JoysScroll/JoysScroll";
import { myDOM } from "@/assets/js/utils.js";
export default {
  name: "infoSearch",
  components: {
    Scroll
  },
  props: {
    typeId: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      aaaa: "",
      searchInfoItem: "",
      searchlist: []
    };
  },
  methods: {
    searchInfoList() {
      // debugger
      this.$axios({
        url: "/joys-rest/joys-admin/message/page",
        method: "get",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN")
        },
        params: {
          messageContent: this.searchInfoItem,
          messageTypeId: this.typeId,
          pageIndex: 1,
          pageSize: 1000
        }
      })
        .then(res => {
          this.searchlist = res.data.rows;
        })
        .catch(error => {
          console.log(error);
        });
    },
    queryImg(id) {
      return (
        "/joys-rest/joys-file/file/browse/one2one/" +
        id +
        "?AUTH-TOKEN=" +
        localStorage.getItem("AUTH-TOKEN")
      );
    },
    returnHistory() {
      this.$emit("childEvent");
      this.searchlist = "";
      console.log("gggggg");
    }
  },
  created() {
    // debugger
    // 节流
    this.$watch(
      "searchInfoItem",
      myDOM.debounce(newQuery => {
        console.log("11", "");
        this.searchInfoList();
      }, 300)
    );
  }
};
</script>
  
  <style scoped lang="less">
.infoSearch_box {
  position: fixed;
  top: 0rem;
  bottom: 0.1rem;
  width: 100%;
  height: 100%;
  z-index: 800;
  overflow: hidden;
  background: #ffffff;
  .infoSearch_title {
    height: 0.44rem;
    width: 100%;
    background: #ffffff;
    box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
    position: relative;
    overflow: hidden;
    .search_box {
      position: absolute;
      top: 0rem;
      left: 0rem;
      width: 100%;
      height: 0.44rem;
      line-height: 0.44rem;
      img {
        width: 0.2rem;
        position: absolute;
        left: 0.085rem;
        top: 0.12rem;
      }
      input {
        padding-left: 0.1rem;
        height: 0.32rem;
        background: rgba(141, 141, 141, 0.05);
        font-family: Regular;
        font-size: 0.14rem;
        color: #001616;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
        margin-top: -0.05rem;
        margin-left: 0.36rem;
        width: 100%;
      }
      input::placeholder {
        font-family: Regular;
        font-size: 0.14rem;
        color: #001616;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
      }
    }
    i {
      display: block;
      height: 0.43rem;
      width: 0.63rem;
      line-height: 0.44rem;
      text-align: center;
      font-family: Regular;
      font-size: 0.14rem;
      color: #001616;
      letter-spacing: -0.34px;
      position: absolute;
      top: 0rem;
      right: 0rem;
      background: #ffffff;
    }
  }
  .infoSearch_list_box {
    margin-top: 0.44rem;
    height: 100%;
    overflow: hidden;
    // margin-bottom: -0.88rem;
    .infoSearch_list {
      background: #ffffff;
      .infoSearch_list_item {
        height: 0.68rem;
        margin-left: 0.18rem;
        padding-right: 0.16rem;

        border-bottom: 1px rgba(207, 207, 207, 0.2) solid;
        .infoSearch_list_item_img {
          float: left;
          width: 0.24rem;
          height: 100%;
          // background: red;
          display: flex;
          justify-content: center;
          align-items: center;
          margin-right: 0.16rem;
          img {
            height: 0.24rem;
          }
        }
        .infoSearch_list_item_info {
          // float: left;
          p {
            padding-top: 0.06rem;
            font-family: Regular;
            font-size: 0.15rem;
            color: #535353;
            letter-spacing: -0.36px;
            line-height: 0.2rem;
            width: 60%;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
          }
          .stylefont {
            padding-top: 0.04rem;
            font-family: Regular;
            font-size: 0.12rem;
            color: #8e8e8e;
            letter-spacing: -0.29px;
            text-align: justify;
            line-height: 0.16rem;

            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }
        }
      }
    }
    .infoSearch_list::after {
      content: "";
      height: 0.44rem;
      display: block;
      width: 100%;
    }
  }

  .infoSearch_none_list {
    font-family: Regular;
    font-size: 0.13rem;
    color: rgba(0, 22, 22, 0.8);
    letter-spacing: 0;
    text-align: center;
    margin-top: 30%;
  }
}
.slide-enter-active,
.slide-leave-active {
  transition: all 0.3s ease;
}
.slide-enter,
.slide-leave-to {
  opacity: 0;
  transform: translate3d(0, 5%, 0);
}
</style>